def isright(n):
    if n%2 != 1:
        return 0
    if n%3 != 2:
        return 0
    if n%5 != 4:
        return 0
    if n%6 != 5:
        return 0
    if n%7 != 0:
        return 0
    return 1
n=7
while 1:
    if isright(n)==1:
        print n
        break
    else:
        n=n+7